_require local "../../../../basis.smi"
_require "../../../data/symbols/main/Loc.smi"
_require "../../../data/types/main/Types.ppg.smi"
(* _require "../../../data/types/main/TypesBasics.smi" *)
(* _require "../../../data/types/main/TypesUtils.smi" *)
(* _require "../../../data/types/main/Unify.smi" *)
(* _require "../../../extensions/usererror/main/UserError.ppg.smi" *)
(* _require "../../../extensions/reflection/main/ReifyUtils.smi" *)
_require local "../../../extensions/reflection/main/ReifiedTyData.smi"
(* _require local "../../../compilerIRs/absyn/main/Absyn.ppg.smi" *)
_require local "../../../compilerIRs/patterncalc/main/PatternCalc.ppg.smi"
(* _require local "../../../compilerIRs/typedcalc/main/TypedCalcUtils.smi" *)
(* _require local "../../../compilerIRs/recordcalc/main/RecordCalcUtils.smi" *)
(* _require local "../../../data/builtin/main/BuiltinPrimitive.ppg.smi" *)
_require local "../../../data/builtin/main/BuiltinTypes.smi"
(* _require local "../../../data/symbols/main/Loc.smi" *)
_require local "../../../data/symbols/main/RecordLabel.smi"
_require local "../../../data/symbols/main/Symbol.smi"
_require local "../../../data/types/main/TypesBasics.smi"
_require local "../../../data/types/main/Unify.smi"
_require local "../../../extensions/debug/main/Bug.smi"
(* _require local "../../../extensions/reflection/main/ReifyUtils.smi" *)
_require local "../../../extensions/userlevelprimitive/main/UserLevelPrimitive.smi"
_require local "../../../libs/ids/main/LocalID.smi"
_require local "../../../libs/list-utils/main/ListSorter.smi"
_require local "./TypeInferenceUtils.smi"
_require "../../../compilerIRs/typedcalc/main/TypedCalc.ppg.smi"
_require local "./CompareTy.smi"

structure CompileDynamicCase =
struct
  exception DynamicCasePatsMustBeGround of TypedCalc.tppat
  val compile : {exp:TypedCalc.tpexp, ty:Types.ty, elemTy:Types.ty, 
                            ruleList:{keyTy : Types.ty,
                                      existTyvars : Types.btvEnv,
                                      existInstTys : Types.ty list,
                                      patTy : Types.ty,
                                      arg : TypedCalc.tppat,
                                      body : TypedCalc.tpexp} list,
                            ruleBodyTy:Types.ty, loc:Loc.loc} 
                           -> Types.ty * TypedCalc.tpexp
end
